$(function () {
    var articleVue = new Vue({
        el: '.data-content',
        data: {
            articles: [],
        }
    })
    // 页数
    var pageIndex = 0;
    // 每页展示5个
    var size = 3;
    // dropload
    $('.data-content').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '',
            // domLoad : '<div class="dropload-load">○加载中...</div>',
            domNoData: '<div class="dropload-noData"></div>'
        },
        loadDownFn: function (me) {
            pageIndex++;
            // 拼接HTML
            var result = '';
            $.ajax({
                type: 'POST',
                url: base + '/catalog/outlineArticles',
                data: {pageIndex: pageIndex, pageSize: size, subjectId: subjectId, gradeId: gradeId},
                success: function (data) {
                    data = JSON.parse(data)
                    var arrLen = data.length;
                    if (arrLen > 0) {
                        for (var i = 0; i < arrLen; i++) {
                            articleVue.articles.push(data[i])
                        }
                        // 如果没有数据
                    } else {
                        // 锁定
                        me.lock();
                        // 无数据
                        me.noData();
                    }
                    // 为了测试，延迟1秒加载
                    setTimeout(function () {
                        // 插入数据到页面，放到最后面
                        $('.data-content').append(result);
                        // 每次数据插入，必须重置
                        me.resetload();
                    }, 1000);
                },
                error: function (xhr, type) {
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    me.resetload();
                }
            });
        }
    });

});